cmake_minimum_required(VERSION 2.8)

set(SIFT sift)
project(${SIFT})

option(SIFT_BUILD_EXAMPLES "Build with examples" ON)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
    string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
endforeach()

set(SIFT_ROOT ${PROJECT_SOURCE_DIR}/)
set(SIFT_SRC_DIR ${SIFT_ROOT}/src)

file(GLOB_RECURSE SRC RELATIVE ${PROJECT_SOURCE_DIR} "${SIFT_SRC_DIR}/*.cpp")
file(GLOB_RECURSE HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "${SIFT_SRC_DIR}/*.h")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")

add_library(${SIFT} ${SRC})
set_property(TARGET ${SIFT} PROPERTY POSITION_INDEPENDENT_CODE ON)

target_include_directories(${SIFT} PUBLIC ${SIFT_SRC_DIR})

if(SIFT_BUILD_EXAMPLES)
  file(GLOB_RECURSE MATCH_SRC "image_match.cpp")
  add_executable(image_match ${MATCH_SRC})

  target_link_libraries(image_match
	  sift
  )
endif()
